Computer systems include at least one processor and memory. The memory stores application program instructions, data, and an operating system. The operating system controls the processor and the memory for system operations and for executing the application program instructions. Processors often have a current privilege level which controls the application instruction execution in the computer system by controlling accessibility to system resources, such as system registers, system instructions, and system memory pages. The current privilege level varies between two or more execution privilege levels.
Typical computer systems do not have a mechanism for an application program to call an operating system function to get into higher privileged code to enable the application program to execute a higher privileged routine directly. In this type of typical computer system, the operating system must increase the privilege level in order to fulfill a call to the higher privileged routine. In this type of typical computer system, the application program executes some instruction which takes an interruption to the operating system and places a processor of the computer system at the highest privilege level. While the processor is at the highest privilege level, the operating system evaluates what is required to resolve the interruption, performs the required higher privileged routine, and returns instruction control flow back to the application program. This interruption and operating system operation is quite expensive in processor time and resources.
Some conventional computer systems have a mechanism for the application program to directly call an operating system function to get into higher privileged code to enable the application program itself to directly execute a higher privileged routine. For example, one such mechanism includes a special privilege promotion instruction performed by the operating system to promote the current privilege level of processor to a higher privilege level. This special privilege promotion instruction typically records some state information, including the previous privilege level, in order to permit a subsequent privilege demotion back to the original privilege level. One type of such special privilege promotion instruction is the PA-RISC gateway instruction. If the privilege promotion instruction is genuine, then the previous privilege level state recorded by the privilege promotion instruction can be trusted. Typically, the privilege promotion instruction is guaranteed to be genuine by employing normal virtual memory protection mechanisms to ensure that the privilege promotion instruction is stored on a memory page which cannot be written at the lower privilege level(s).
Even though any information recorded at a lower privilege level cannot be trusted and must be checked at a higher privilege level, the privilege promotion instruction being placed on a memory page which cannot be written at the lower privilege level and the privilege promotion instruction recording the previous privilege level state permits the previous privilege level state to be trusted. However, the privilege promotion instruction writing the previous privilege level state typically requires special processor data paths and control logic not required for any other purpose. In addition, any state for the privilege promotion written at a lower privilege level rather than by the privilege promotion instruction requires extra system instructions executing at the higher privilege level to check the validity of the state written at the lower privilege level, thus lowering the performance of the privilege promotion.
For reasons stated above and for other reasons presented in greater detail in the Description of the Preferred Embodiments section of the present specification, a computer system is desired which employs a privilege promotion instruction for promoting a current privilege level of a processor in the computer system which improves performance of the privilege promotion and does not require special processor data paths and control logic to perform the privilege promotion instruction.